#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //部署随机数种子
    srand(time(nullptr));
}

Widget::~Widget()
{
    delete ui;
}

//同意槽函数
void Widget::on_pushButton_clicked()
{
    ui->label->setText("谢谢老板同意");
}

//拒绝槽函数
void Widget::on_pushButton_2_clicked()
{
    //获取窗口的宽度和高度
    int width = this->geometry().width();
    int height = this->geometry().height();

    //生成随机位置
    int random_x = rand() % width;
    int random_y = rand() % height;

    QRect rect = ui->pushButton_2->geometry();
    ui->pushButton_2->setGeometry(random_x, random_y, rect.width(), rect.height());
}
